
<?php

/**
 * Description of QueryMember
 *
 * @author Administrator
 */
abstract class TrjhCommand {

    public $app;
    public $logger;
    public $valid;
    public $errorCode;

    // We'll use a constructor, as you can't directly call a function
    // from a property definition.
    public function __construct($app) {
        $this->app = $app;
        $this->logger = $app->logger;
        $this->errorCode = $app->errorCode;
    }

   
    protected function run($param) {
        $this->logger->info("传入的参数为" . json_encode($param));
    }

    //异常返回
    protected function errorHandle($errorCode) {
        if (!isset($this->errorCode[$errorCode])) {
            $this->logger->error("异常，未登记的异常类型$errorCode");
            $ret = array('state' => $errorCode, 'message' => '系统繁忙');
            return $ret;
        }
        $message = $this->errorCode[$errorCode];
        $this->logger->error("异常" . $message);
        $ret = array('state' => $errorCode, 'message' => $message,'data'=>'');
        return $ret;
    }

    //正常返回
    protected function returnHandle($data) {
        $this->logger->debug("返回" . json_encode($data));
        $ret = array('state' => '200', 'message' => 'ok', 'data' => $data);
        return $ret;
    }
     //正常返回，操作失败
    protected function returnFalse($message) {
        $this->logger->debug("返回" . json_encode($message));
        $ret = array('state' => '201', 'message' => $message, 'data' => '');
        return $ret;
    }
    
}
